<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //1. 二进制/八进制的写法
        let num1 = 100;
        let num2 = 0x100;
        let num3 = 0b100;
        let num4 = 0o100;
        console.log(num1, num2, num3, num4); //100 256 4 64

        //2. Number.isFinite & Number.isNaN
        let num5 = Number.isFinite(100)
        let num6 = Number.isFinite(100 / 0)
        let num7 = Number.isFinite(Infinity)
        let num8 = Number.isFinite("100")
        console.log(num5, num6, num7, num8) //true false false false
        //Number.isFinite对于非数值一律返回false，Number.isNaN只有对于NaN才返回true
        let num9 = Number.isNaN(100)
        let num10 = Number.isNaN(NaN)
        let num11 = Number.isNaN("twj")
        let num12 = Number.isNaN("100")
        console.log(num9, num10, num11, num12) //false true false false

        //3. Number.isInteger
        let num13 = Number.isInteger(100)
        let num14 = Number.isInteger(100.0)
        let num15 = Number.isInteger("kerwin")
        let num16 = Number.isInteger("100")
        console.log(num13, num14, num15, num16) //true true false false

        //4. Number.EPILON：极小常量 
        //它表示1与大于1的最小浮点数之间的差。2.220446049250313e-16
        function isEqual(a, b) {
            return Math.abs(a - b) < Number.EPSILON
        }
        console.log(isEqua1(0.1 + 0.2, 0.3)) //true
        console.log(0.1 + 0.2 === 0.3) //fa1se

        //5. Math.trunc：将小数部分抹掉，返回一个整数
        console.log(Math.trunc(1.2)) //1
        console.log(Math.trunc(1.8)) //1
        console.log(Math.trunc(-1.8)) //-1
        console.log(Math.trunc(-1.2)) //-1

        //6. Math.sign：用来判断一个数到底是正数、负数、还是零。对于非数值，会先将其转换为数值。
        Math.sign(-100) // -1
        Math.sign(100) // +1
        Math.sign(o1) // +0
        Math.sign(-0) // -0
        Math.sign("kerwin") // NaN
    </script>
</body>

</html>